<?php

/**
 * Class Role
 * - cake acl initdb
 */
class Role extends AppModel {

	public $useTable = 'Roles';

	public $actsAs = ['Acl' => ['type' => 'requester']];

	/**
	 * parentNode method
	 *
	 * @return array|null
	 */
	public function parentNode() {
		if (empty($this->id)) {
			return null;
		}
		$roleId = Hash::get($this->data, 'Role.parent_id');
		if (empty($roleId)) {
			$roleId = $this->field('parent_id');
		}
		if (empty($roleId)) {
			return null;
		} else {
			return array('Role' => array('id' => $roleId));
		}
	}
}
